import requests
from bs4 import BeautifulSoup


def get_article_name(name):
    '''
    get the stand wiki name from wikipedia
    it is slow, Better used in multithreaded
    '''
    search_url = r'https://en.wikipedia.org/w/index.php?search=%s&title=Special:Search&go=Go'%name
    response = requests.get(search_url)
    soup = BeautifulSoup(response.text, 'html5lib')
    title = soup.find('title').string
    if 'Search results' in title:
        return False
    else:
        return title.replace(' - Wikipedia, the free encyclopedia','')

def test():
    '''
    the test function
    '''
    for each in ['ibm','International Business Machines Corporation','i.b.m.','I.B.M.','IBM']:
        print(get_article_name(each))
    

if __name__ == '__main__':
    test()